<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="/WEB-INF/jsp/taglibs-struts2.jsp" %>

<form name="getPriceForm" action="flightQueryAction!getPrice.action" method="post">

<input type="hidden" name="passengersNum" value="<c:out value="${passengersNum}"/>"/>
<input type="hidden" name="bunk" value="<c:out value="${bunk}"/>"/>

<div class="right">
<div class="right600"><h2 class="r201">航班信息</h2><h2 class="r202"/></div>

<c:forEach var="item" items="${resultMap}">
<c:set var="company" value="${item.key}"/>
<div class="right600b"><h2 class="r203"><input type="checkbox" value="checkbox" name="checkbox"/><c:out value="${company.comChineseName}"/></h2></div>
<div class="r205"><h2 class="r50">去向</h2><h2 class="r100">航班号</h2><h2 class="r100">城市对</h2><h2 class="r100">起飞时间</h2><h2 class="r100">降落时间</h2><h2 class="r100">航班班期</h2><h2 class="r50">选择</h2></div>
<!--这里循环-->

<c:set var="flightList" value="${item.value}"></c:set>
<c:set var="toList" value="${flightList[0]}"/>
<c:set var="backList" value="${flightList[1]}"/>

<c:forEach var="flArr" items="${toList}" varStatus="toStatus">
  <c:forEach var="fl" items="${flArr}" varStatus="status">
    <c:if test="${status.first}"><div class="r206"><h2 class="r50"><font color="#009900">去程</font></h2></c:if>
    <h2 class="r100"><c:out value="${fl.planeInfo.planeno}"/></h2><h2 class="r100"><c:out value="${fl.planeInfo.departure.airportChineseName}"/>-<c:out value="${fl.planeInfo.destination.airportChineseName}"/></h2><h2 class="r100"><fmt:formatDate value="${fl.takeoffDate}" pattern="yyyy-MM-dd"/></h2><h2 class="r100"><fmt:formatDate value="${fl.putdownDate}" pattern="yyyy-MM-dd"/></h2><h2 class="r100">周<c:forEach var="day" items="${fl.avaiableDays}" varStatus="dayStatus"><c:if test="${day}"><c:out value="${dayStatus.index+1}"/>,</c:if></c:forEach></h2><c:if test="${status.first}"><h2 class="r50"><input type="radio" value="<c:out value="${toStatus.index}"/>" name="<c:out value="${company.twocode}_radioBtnTo"/>"/></h2></c:if></div>
    <input type="hidden" name="airCom" value="<c:out value="${company.twocode}"/>"/>
    <input type="hidden" name="<c:out value="${company.twocode}"/>_to_${toStatus.index}_${status.index}_takeoffDate" value="<fmt:formatDate value="${fl.takeoffDate}" pattern="yyyy-MM-dd"/>"/>
    <input type="hidden" name="<c:out value="${company.twocode}"/>_to_${toStatus.index}_${status.index}_putdownDate" value="<fmt:formatDate value="${fl.putdownDate}" pattern="yyyy-MM-dd"/>"/>
    <input type="hidden" name="<c:out value="${company.twocode}"/>_to_${toStatus.index}_${status.index}_planeInfoId" value="<c:out value="${fl.planeInfo.id}"/>"/>
    <c:forEach var="day" items="${fl.avaiableDays}" varStatus="dayStatus">
      <c:if test="${day}"><input type="hidden" name="<c:out value="${company.twocode}"/>_to_${toStatus.index}_${status.index}_avaiableDay" value="<c:out value="${dayStatus.index}"/>"/></c:if>
    </c:forEach>
  </c:forEach>
</c:forEach>

<c:forEach var="flArr" items="${backList}" varStatus="toStatus">
  <c:forEach var="fl" items="${flArr}" varStatus="status">
    <c:if test="${status.first}"><div class="r206"><h2 class="r50"><font color="#ff9900">回程</font></h2></c:if>
    <h2 class="r100"><c:out value="${fl.planeInfo.planeno}"/></h2><h2 class="r100"><c:out value="${fl.planeInfo.departure.airportChineseName}"/>-<c:out value="${fl.planeInfo.destination.airportChineseName}"/></h2><h2 class="r100"><fmt:formatDate value="${fl.takeoffDate}" pattern="yyyy-MM-dd"/></h2><h2 class="r100"><fmt:formatDate value="${fl.putdownDate}" pattern="yyyy-MM-dd"/></h2><h2 class="r100">周<c:forEach var="day" items="${fl.avaiableDays}" varStatus="dayStatus"><c:if test="${day}"><c:out value="${dayStatus.index+1}"/>,</c:if></c:forEach></h2><c:if test="${status.first}"><h2 class="r50"><input type="radio" value="<c:out value="${toStatus.index}"/>" name="<c:out value="${company.twocode}_radioBtnBack"/>"/></h2></c:if></div>
    <input type="hidden" name="airCom" value="<c:out value="${company.twocode}"/>"/>
    <input type="hidden" name="<c:out value="${company.twocode}"/>_back_${toStatus.index}_${status.index}_takeoffDate" value="<fmt:formatDate value="${fl.takeoffDate}" pattern="yyyy-MM-dd"/>"/>
    <input type="hidden" name="<c:out value="${company.twocode}"/>_back_${toStatus.index}_${status.index}_putdownDate" value="<fmt:formatDate value="${fl.putdownDate}" pattern="yyyy-MM-dd"/>"/>
    <input type="hidden" name="<c:out value="${company.twocode}"/>_back_${toStatus.index}_${status.index}_planeInfoId" value="<c:out value="${fl.planeInfo.id}"/>"/>
    <c:forEach var="day" items="${fl.avaiableDays}" varStatus="dayStatus">
      <c:if test="${day}"><input type="hidden" name="<c:out value="${company.twocode}"/>_back_${toStatus.index}_${status.index}_avaiableDay" value="<c:out value="${dayStatus.index}"/>"/></c:if>
    </c:forEach>
  </c:forEach>
</c:forEach>

</c:forEach>

<div><input type="submit" name="getPrice" value="获取价格" onclick="return submitGetPrice()"/></div>

</div>
</form>

<script type="text/javascript">
function submitGetPrice() {
var inputs = document.getElementsByTagName("input");
var radios = [];
for(var i = 0; i < inputs.length; i ++) {
  if(inputs[i].type == 'radio') {
    radios.push(inputs[i]);
  }
}
var bSel = false;
for(i = 0; i < radios.length; i ++) {
  if(radios[i].checked == true) {
    bSel = true;
    break;
  }
}

if(!bSel) {
  alert("请选择航班");
  return false;
}
return true;
}
</script>